<script setup>
import {ref} from 'vue';
const info = ref('我是一个初始值');
const user = ref({
  username: '',
  password: '',
  gender: 'male'
})
const reg = () => {
  console.log(user.value);
  console.log(user.value.username);
  console.log(user.value.password);
  console.log(user.value.gender);
  alert('注册成功');
}
</script>

<template>
  <h1>双向绑定</h1>
  <input type="text" v-model="info" >{{info}}
  <h3>用户注册</h3>
  <input type="text" v-model="user.username" placeholder="请输入用户名">
  <input type="password" v-model="user.password" placeholder="请输入密码">
  <br>性别:
  <input type="radio" name="gender" v-model="user.gender" value="male">男
  <input type="radio" name="gender" v-model="user.gender" value="female">女
  <br>
  <button @click="reg">点击提交</button>
</template>

<style scoped>

</style>